//
//  FifthVideoTableViewCell.m
//  Project_B
//
//  Created by 张闯的mac pro on 15/11/29.
//  Copyright © 2015年 张闯. All rights reserved.
//

#import "FifthVideoTableViewCell.h"
#import "FifthVideoModel.h"
#import "UIImageView+WebCache.h"

@interface FifthVideoTableViewCell ()

@property (nonatomic, retain) UIImageView *imgView;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *timeLabel;

@end

@implementation FifthVideoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.imgView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imgView];
        
        self.titleLabel = [[UILabel alloc] init];
        [self.titleLabel setFont:[UIFont boldSystemFontOfSize:16]];
        self.titleLabel.textColor = [UIColor whiteColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.titleLabel];
        
        self.timeLabel = [[UILabel alloc] init];
        [self.timeLabel setFont:[UIFont systemFontOfSize:14]];
        self.timeLabel.textColor = [UIColor whiteColor];
        self.timeLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.timeLabel];
        
    }
    
    return self;
}

- (void)setFifModel:(FifthVideoModel *)fifModel
{
    if (_fifModel != fifModel) {
        _fifModel = fifModel;
    }
    
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:fifModel.coverForFeed] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
    self.titleLabel.text = fifModel.title;
    
    NSString *str1 = fifModel.category;
    NSString *min = [NSString stringWithFormat:@"%02ld", fifModel.duration.integerValue / 60];
    NSString *sec = [NSString stringWithFormat:@"%02ld", fifModel.duration.integerValue % 60];
    
    self.timeLabel.text = [NSString stringWithFormat:@"#%@ / %@′%@″", str1, min, sec];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.imgView.frame = self.contentView.frame;
    self.titleLabel.frame = CGRectMake(90, 85, 200, 20);
    self.timeLabel.frame = CGRectMake(140, 110, 100, 20);
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
